<!-- 查看 -->
<template>
  <base-breadcrumb :title="$route.meta.title">
    <a-spin :spinning="spinning">
      <a-card>
        <WarningFormCard :form="formWarningInfo" form-type="disable"></WarningFormCard>
      </a-card>
      <a-card>
        <title-name title="项目拟采取措施" />
        <ProposedMeasuresCard :form="formrPoposedMeasuresInfo" form-type="disable"></ProposedMeasuresCard>
      </a-card>
      <!-- 未到验收流程，及验收状态为“-”的，不显示验收记录版块 -->
      <a-card v-if="showMeasure">
        <title-name title="验收记录" />
        <AcceptanceRecordCard :form="formDataSource" form-type="disable"></AcceptanceRecordCard>
      </a-card>
      <div class="tool-btns page-btn-right-top">
        <a-button class="ml20" type="primary" @click="handleClose"> 关闭 </a-button>
      </div>
    </a-spin>
  </base-breadcrumb>
</template>

<script>
import WarningFormCard from './components/WarningFormCard.vue'
import ProposedMeasuresCard from './components/ProposedMeasuresCard.vue'
import AcceptanceRecordCard from './components/AcceptanceRecordCard.vue'
import { getProjectCycleEarlyWarnById } from '@/api/project/warning'
import mixins from './mixins.js'
export default {
  name: 'Look',
  mixins: [mixins],
  data() {
    return {
      spinning: false,
      // 预警信息
      formWarningInfo: {
        projectCode: '', // 项目编号
        projectId: '', // 项目id
        projectName: '', // 项目名称
        branchId: '', // 分公司id
        branchName: '', // 分公司名称
        basicInfo: '', // 项目基本情况
        warnInfo: '', // 工期预警信息
        warnLevel: '', // 预警级别
        receivingUnit: '', // 接收单位
        recipientName: '', // 接收人
        recipientId: '', // 接收人id
        creatorName: '', // 检查人
        createTime: '', // 检查时间
        fileInfoList: [] // 附件信息
      },
      // 拟采取措施
      formrPoposedMeasuresInfo: {
        checkStatus: '',
        measureStatus: '',
        checkUser: '', // 自检人
        submitTime: '', // 时间-当前日期
        measure: '', // 拟采取措施
        measureFileInfoList: [] // 文件
      },
      // 验收记录
      formDataSource: []
    }
  },

  components: { WarningFormCard, ProposedMeasuresCard, AcceptanceRecordCard },

  computed: {
    showMeasure() {
      if (this.formrPoposedMeasuresInfo.checkStatus === '') return false
      return (
        this.filterAcceptanceRecordName(this.formrPoposedMeasuresInfo.checkStatus, this.formrPoposedMeasuresInfo) !==
        '-'
      )
    }
  },

  created() {
    this.getItemDetail(this.$route.query._id)
  },

  mounted() {},

  methods: {
    // 关闭
    handleClose() {
      this.$close()
    },
    getItemDetail(id) {
      this.spinning = true
      getProjectCycleEarlyWarnById({ id }).then((res) => {
        Object.keys(this.formWarningInfo).map((k) => {
          this.formWarningInfo[k] = res.data[k]
        })
        Object.keys(this.formrPoposedMeasuresInfo).map((k) => {
          this.formrPoposedMeasuresInfo[k] = res.data[k]
        })
        this.formrPoposedMeasuresInfo['checkUser'] = res.data['selfCheckName']
        this.formrPoposedMeasuresInfo['submitTime'] = res.data['selfCheckTime']
        this.formDataSource = res.data.recordList

        this.spinning = false
      })
    }
  }
}
</script>
<style lang='less' scoped>
</style>